﻿<html>
	<head>
		<link rel="stylesheet" href="http://localhost:8080/Anagram/css/css.css" type="text/css"; charset="UTF-8">
	</head>
	
	<body>
	<%@ page import="util.*, objects.*, objects.*, dispatchers.*, java.util.*" %>
		<div id="main">
		
			<%!
				DBManager dbManager = new DBManager("anagram", "root", "root");
				DBArticleDispatcher articleDispatcher = new DBArticleDispatcher(dbManager, "articles");
			%>
			
			<%@ include file="/jsp/general/header.jsp"%>
			<%@ include file="/jsp/general/mainmenu.html"%>
			
		
		<div id="article">
			<% 
				int articleID=-1;
				try{
					articleID = Integer.parseInt(request.getParameter("articleID"));
				}catch(NumberFormatException e){}
				
				Article article = articleDispatcher.getArticle(articleID);
				if(article!=null){
			%>
			
			<h2><%= article.getTitle()%></h2><br>
			<hr>
			<%= article.getBody()%>
				
				
			<%}else{%>
				Статья не найдена.
			<%}%>
		</div>
		
		<%	if(session!=null){
				User userAdmin = (User)session.getAttribute("user");
				if(userAdmin!=null && userAdmin.getSecurityLevel()==3){%>
			<div class="rightmenu">
				<a href="/Anagram/editArticle?action=new">Новая</a>
				<a href="http://localhost:8080/Anagram/editArticle?articleID=<%=articleID%>&action=edit">Редактировать</a>
				<a href="/Anagram/editArticle?articleID=<%=articleID%>&action=delete">Удалить</a>
			</div>
		<%}}%>
	
		
		<%@ include file="/jsp/general/bottom.jsp"%>
	</div>
	
	</body>
</html>